<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>装修验收</title>
<script type="text/javascript">
	var roofArray;
	var wallArray;
	var landArray;
	//初始化页面数据,传入房间类型
	function initCheckDate(roomType){
		var wall=${requestScope.checkWall};
		var roof=${requestScope.checkRoof};
		var floor=${requestScope.checkFloor};
		//初始化 带删除附件数组
		roofArray=new Array();
		wallArray=new Array();
		landArray=new Array();
		
		//给墙面赋值
		checkEachWall(wall,roomType,initCheckReceiveWallAddForm);
		//顶 赋值
		checkEach(roof,roomType,initDecorationProof);
		//地面赋值
		checkEach(floor,roomType,initDecorationLandData);
	}
	//循环地面、顶数组
	function checkEach(data,roomType,fun){
		var t;
		$.each(data,function(i,v){
			if(v.roomType==roomType){
				t=v;
				return false;
			}
		});
		fun(t);
	}
	//由于墙面特殊，所以独立写出循环方法
	function checkEachWall(data,roomType,fun){
		var arr=new Array();
		$.each(data,function(i,v){
			if(v.roomType==roomType){
				arr.push(v);
			}
		});
		fun(arr);
	}
	
	function initSelectData() {
		var html = "";
		var arr = [ "玄关", "起居室", "餐厅", "厨房", "储物间", "卫生间", "房间", "阳台", "平台" ];
		for (var i = 0; i < arr.length; i++) {
			html = "<option value=\"" + arr[i] + "\">" + arr[i] + "</option>";
			$("#roomType").append(html);
		}
	}
	function change(obj) {
		var history = parent.$("#history").val();
		$("#tabChoose li").attr("class", "");
		$("#chooseTab .tab-pane").removeClass("active");
		$('.cmxform').find('.xuanguanHide').show();//显示玄关的无用的设置
		$('.cmxform').find('.qijushiHide').show();//显示起居室的无用的设置
		$('.cmxform').find('.cantingHide').show();//显示起餐厅的无用的设置
		$('.cmxform').find('.cantingHide').show();//显示起厨房的无用的设置
		$('.cmxform').find('.chuwujianHide').show();//隐藏起储物间的无用的设置
		$('.cmxform').find('.weishengjianHide').show();//隐藏起卫生间的无用的设置；
		$('.cmxform').find('.yangtaiHide').show();//隐藏起阳台的无用的设置
		$('.cmxform').find('.pingtaiHide').show();//隐藏起平台的无用的设置
		var val = $(obj).val();
		if (val == "玄关") {
			$("#tab-wall").hide();
			$("#tab-land").show();
			$("#tab-top").show();
			$('.cmxform').find('.xuanguanHide').hide();//隐藏玄关的无用的设置
		} else if (val == "平台") {
			$("#tab-wall").show();
			$("#tab-land").show();
			$("#tab-top").hide();
			$('.cmxform').find('.pingtaiHide').hide();//隐藏起平台的无用的设置
		} else {
			$("#tab-wall").show();
			$("#tab-land").show();
			$("#tab-top").show();
			if(val == "起居室"){
				$('.cmxform').find('.qijushiHide').hide();//隐藏起居室的无用的设置	
			} else if (val == "餐厅") {
				$('.cmxform').find('.cantingHide').hide();//隐藏起餐厅的无用的设置
			} else if (val == "厨房") {
				$('.cmxform').find('.chufangHide').hide();//隐藏起厨房的无用的设置
			} else if (val == "储物间") {
				$('.cmxform').find('.chuwujianHide').hide();//隐藏起储物间的无用的设置
			}else if (val == "卫生间") {
				$('.cmxform').find('.weishengjianHide').hide();//隐藏起卫生间的无用的设置
			}else if (val == "阳台") {
				$('.cmxform').find('.yangtaiHide').hide();//隐藏起阳台的无用的设置
			}	
		}
		$("#tab-land").attr("class", "active");
		$("#tab2-4-1").attr("class", "tab-pane active ");
		//window.location.href=window.location.href;
		//房屋类型变动时  进行赋值
		initCheckDate(val);
		if(history=='yes'){
			$("input").attr("readonly", true);
			$("div[id^='filePicker']").css("display","none");
			$("span.uploadcancel").hide();
			$(".anniu").hide();
		}
	}
</script>
<style type="text/css">
.main-top tr {
	height: 35px;
}

.leftt {
	text-align: center;
	width: 100px
}

.neirong {
	width: 220px;
}

input[type="search"], input[type="text"] {
	height: 30px;
	margin-bottom: 0px;
	width: 200px
}

.mingcheng {
	display: -moz-inline-box;
	display: inline-block;
	width: 100px;
}

.select2-container .select2-selection--single {
	height: 30px
}
</style>
</head>
<body>
	<div class="page-container" style="padding:10px 10px 0px 20px;">
		<div style="margin-bottom: 15px">
			<span class="mingcheng">房屋类型</span><span> 
			<select name="roomType" id="roomType" onchange="change(this)">
			</select></span>
		</div>

		<div id="usual2" class="usual">

			<div class="tabbable tabs-left">
				<!-- Nav tabs -->
				<ul class="nav nav-tabs" role="tablist" id="tabChoose">
					<li id="tab-land"><a href="#tab2-4-1" data-toggle="tab">地面</a></li>
					<li id="tab-wall"><a href="#tab2-4-2" data-toggle="tab">墙面</a></li>
					<li id="tab-top"><a href="#tab2-4-3" data-toggle="tab">顶</a></li>
				</ul>

				<!-- Tab panes -->
				<div class="tab-content" id="chooseTab">

					<!-- 地面start -->
					<div class="tab-pane " id="tab2-4-1">
						<jsp:include page="decorationLand-add.jsp"></jsp:include>
					</div>
					<!-- 地面end -->
					<!-- 墙面start -->
					<div class="tab-pane " id="tab2-4-2">
						<jsp:include page="decorationWalls-add.jsp"></jsp:include>
					</div>
					<!-- 墙面end -->
					<!-- 顶start -->
					<div class="tab-pane" id="tab2-4-3">
						<jsp:include page="decorationProof-add.jsp"></jsp:include>
					</div>
					<!-- 顶end -->
				</div>
			</div>
		</div>
	</div>
<script type="text/javascript">
	$(function() {
		$(".js-example-tags").select2({
			tags : true //可搜索
		});
		
		var stair=${requestScope.stairMaterial};//楼梯材料
		var decorativeMaterials=${requestScope.decorativeMaterials};//装饰材料
		//楼梯材料赋值
		initStairMaterialData(stair);
		//装饰材料下拉选项
	 	initDecorativeMaterialsData(decorativeMaterials);
		initSelectData();
		//初始化地面(decorationland-add页面)select2 
		initSel2();
		var s = $("#roomType").select2();
		if(parent.houseType==null || parent.houseType==""){
			s.val("玄关").trigger("change");
		}else{
			s.val(parent.houseType).trigger("change");
		}
		
	});
</script>
</body>

</html>

